# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Daichi Shinozaki <dsdseg@gmail.com>
# Contributor: Christopher Arndt <aur -at- chrisarndt -dot- de>

pkgname=python-paho-mqtt
pkgver=1.6.1
pkgrel=2
url="https://www.eclipse.org/paho/clients/python"
pkgdesc="Python client library for MQTT v3.1 and v3.1.1"
depends=('python')
checkdepends=('python-pytest' 'python-pytest-runner' 'python-six')
makedepends=('python-setuptools')
license=('custom')
arch=('any')
source=($pkgname-$pkgver.tar.gz::https://github.com/eclipse/paho.mqtt.python/archive/v${pkgver}.tar.gz)
sha256sums=('6e35c1be242a901fc9c00bad7d37b5cc4a497f398dfceb4ed0d8018a959be650')

prepare() {
  cd paho.mqtt.python-${pkgver}
  sed -i '/addopts/d' setup.cfg
}

build() {
  cd paho.mqtt.python-${pkgver}
  python setup.py build
}

check() {
  cd paho.mqtt.python-${pkgver}
  PYTHONPATH=$PWD/src pytest tests
}

package_python-paho-mqtt() {
  cd paho.mqtt.python-${pkgver}
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
